package com.sd.springboot.experiment_1.util;

import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class MyCommandLineRunner implements CommandLineRunner {

    ApplicationContext context;

    MyCommandLineRunner(ApplicationContext context){
        super();
        this.context = context;
    }

    @Override
    public void run(String... args) throws Exception {
        System.out.println("》》》》》》》输出容器中所有的Bean《《《《《《《《");
        String[] beanDefinitionNames = context.getBeanDefinitionNames();
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println(beanDefinitionName);
        }
    }
}
